package com.users.rn.rncommon.manager;


import java.util.HashMap;

/**
 * 作者：wolf on 12/22/20 14:57
 * <p>
 * 邮箱：bluce
 */

public class ALHReactDebugHostManager {
    private volatile static ALHReactDebugHostManager instance = null;
    private final HashMap<String, ALHReactNativeHost> mHostCache = new HashMap<>();

    public static ALHReactDebugHostManager getInstance() {
        if (instance == null) {
            synchronized (ALHReactDebugHostManager.class) {
                instance = new ALHReactDebugHostManager();
            }
        }
        return instance;
    }

    public ALHReactNativeHost get(String pluginId) {
        ALHReactNativeHost host = mHostCache.get(pluginId);
        if (host == null) {
            host = ALHReactEnvManager.getInstance().getDebugReactNativeHost();
            mHostCache.put(pluginId, host);
        }
        return host;
    }

    public void remove(String pluginId) {
        mHostCache.remove(pluginId).clear();
    }
}
